#!/usr/bin/env node

const Koa = require('koa');
const log = console.log;
const app = new Koa();
app.listen(8080);

app.use((ctx, next) => {  //M-power-logger
    const start = Date.now();
    next();//调下一个
    const end = Date.now();
    log(`${ctx.method} ${ctx.path} ${end - start}ms`);
});

app.use((ctx, next) => {  //M-hello
    log('hello Koa!');
    ctx.body = 'ok';
});

